﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Automation.Peers;
using System.Windows;
using System.Windows.Controls;
using Wpf.Ui.Controls;
using System.Windows.Input;
using System.Windows.Media;

namespace ClientAppraise.Controls
{
    public class ZxErrCard : ContentControl
    {

        /// <summary>
        /// Property for <see cref="Icon"/>.
        /// </summary>
        public static readonly DependencyProperty IconProperty = DependencyProperty.Register(
            nameof(Icon),
            typeof(IconElement),
            typeof(ZxErrCard),
           // new PropertyMetadata(new SymbolIcon(SymbolRegular.ErrorCircle24))
            new PropertyMetadata(null)
        );

        /// <summary>
        /// Property for <see cref="CornerRadius"/>
        /// </summary>
        public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register(
            nameof(CornerRadius),
            typeof(CornerRadius),
            typeof(ZxErrCard),
            new PropertyMetadata(new CornerRadius(0))
        );



        /// <summary>
        /// Gets or sets displayed <see cref="IconElement"/>.
        /// </summary>
        [Bindable(true), Category("Appearance")]
        public IconElement? Icon
        {
            get => (IconElement)GetValue(IconProperty);
            set => SetValue(IconProperty, value);
        }

        /// <summary>
        /// Gets or sets the corner radius of the control.
        /// </summary>
        [Bindable(true), Category("Appearance")]
        public CornerRadius CornerRadius
        {
            get => (CornerRadius)GetValue(CornerRadiusProperty);
            set => SetValue(CornerRadiusProperty, value);
        }


        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            FrameworkElement element = (FrameworkElement)Template.FindName("ChevronIcon", this);
            element.MouseLeftButtonUp += Element_MouseLeftButtonUp;

        }

        private void Element_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            var pEle = (Panel)VisualTreeHelper.GetParent(this);

           pEle.Children.Remove(this);
        }
    }
}
